#include <head.h>

int main(int argc, char const *argv[])
{
    if (argc < 3)
    {
        printf("格式错误 : %s file1 file2 .....\n", argv[0]);
        return 0;
    }
    int fd = open("newfile.txt", O_RDWR | O_CREAT, 0666);
    OPEN_ERR(fd);
    for (int i = 1; i < argc; i++)
    {
        int fd1 = open(argv[i], O_RDONLY);
        OPEN_ERR(fd1);
        char buf[1024];
        int len = 0;
        while ((len = read(fd1, buf, sizeof(buf))) > 0)
        {
            write(fd, buf, len);
        }
        close(fd1);
    }
    close(fd);
    return 0;
}
